{% extends "home/common.html" %}
{% block content %}
<!-- //网站头部 -->

<div id="mr-mainbody" class="container mr-mainbody">
    <div class="row">
        <!-- 显示订单列表 -->
        <div id="mr-content" class="mr-content col-xs-12">
            <div id="mrshop" class="mrshop common-home">
                <div class="container_oc">
                    <div class="row">
                        <div id="content_oc" class="col-sm-12">
                            <h1>我的订单</h1>
                            <div class="table-responsive cart-info">
                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <td></td>
                                        <td class="text-center image">订单号</td>
                                        <td class="text-center name">产品名称</td>
                                        <td class="text-center name">购买数量</td>
                                        <td class="text-center name">单价</td>
                                        <td class="text-center name">消费金额</td>
                                        <td class="text-center quantity">收货人姓名</td>
                                        <td class="text-center price">收货人手机</td>
                                        <td class="text-center total">下单日期</td>
                                        <td class="text-center total">订单状态</td>

                                    </tr>
                                    </thead>
                                    <tbody>
                                    {% for item in orders%}
                                    <tr>
                                        <td>
                                            <input type="checkbox"
                                                   id="{{item.orders.id}}"
                                                   value="{{item.orders.status}}"
                                                   class="order_box" name="order_box_name">
                                        </td>
                                        <td class="text-center image" width="10%">{{item.orders.id}}</td>
                                        <td class="text-center name">{{item.goods.name}}</td>
                                        <td class="text-center quantity">{{item.number}}件</td>
                                        <td class="text-center quantity">{{item.goods.current_price}}元</td>
                                        <td class="text-center quantity">{{item.number*item.goods.current_price}}元</td>
                                        <td class="text-center quantity">{{item.orders.recevie_name}}</td>
                                        <td class="text-center quantity">{{item.orders.recevie_tel}}</td>
                                        <td class="text-center quantity">{{item.orders.addtime}}</td>
                                        <td class="text-center quantity">{{item.orders.status_name}}</td>
                                    </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <br/><br/>
                    <div class="row">
                        <div class="col-sm-12">
                            <br/>
                            <br/>
                            <div class="buttons">
                                <div class="pull-right">
                                    <!--                                    <a href="{{url_for('home.index')}}"-->
                                    <!--                                       class="tigger btn btn-primary btn-primary">继续购物</a>-->
<!--                                    <a onclick="doOrder(1)"-->
<!--                                       class="tigger btn btn-primary btn-primary">发货</a>-->
                                    <a href="{{url_for('home.index')}}"
                                       class="tigger btn btn-primary btn-primary">继续购物</a>
                                    <a onclick="doOrder(2)"
                                       class="tigger btn btn-primary btn-primary">确认收货</a>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
        <!-- //显示订单列表 -->
    </div>
</div>
<script type="text/javascript" src="{{url_for('static',filename='home/js/jBox/jquery-1.4.2.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='home/js/jBox/jquery.jBox-2.3.min.js')}}"></script>
<link type="text/css" rel="stylesheet" href="{{url_for('static',filename='home/js/jBox/Skins2/Pink/jbox.css')}}"/>
<script type="text/javascript">
    function addUnique(arr, element) {
        if (!arr.includes(element)) {
            arr.push(element);
        }
    }

    function doOrder(type) {
        var id = document.getElementsByName('order_box_name');
        var value = new Array();
        for (var i = 0; i < id.length; i++) {
            if (id[i].checked) {
                addUnique(value, id[i].id)
            }
        }
        console.log(value.toString())
        if (value.length > 0) {
            window.location.href = '/update_order_status?id=' + value + "&type=" + type
        }
    }

</script>
<!-- // 使用jBox插件实现一个支付对话框 -->
{% endblock %}
